package com.example.utils;

import org.apache.commons.lang3.RandomStringUtils;

import java.util.Random;

public class TestDataGenerator {
    Random rnd = new Random();

    public String getRandomString(int length){
        return RandomStringUtils.randomAlphabetic(length);
    }

    public String getRandomNumericString(int maxLength){
        int length = rnd.nextInt(maxLength);
        return RandomStringUtils.randomNumeric(length);
    }

    public String getRandomAlphanumericString(int length) {
        return RandomStringUtils.randomAlphanumeric(length);
    }

    /*
    Return random alphabetic string with random length between 0 (inclusive) and the maxLength (exclusive)
     */
    public String getRandomStringWithRandomLength(int maxLength){
        int length = rnd.nextInt(maxLength);
        return RandomStringUtils.randomAlphabetic(length);
    }

    public String getRandomEmail(){
        int userName = rnd.nextInt(10);
        int domain = rnd.nextInt(6);
        while (domain == 0 ) {
            domain = rnd.nextInt(6);
        }

        String email = RandomStringUtils.randomAlphabetic(userName) + "@" + RandomStringUtils.randomAlphabetic(domain) + ".com";
        return email;
    }

    public String getRandomPhone(){
        return ("7" + RandomStringUtils.randomNumeric(10));
    }

    public String getRandomYear(){
        return ("19" + RandomStringUtils.randomNumeric(2));
    }

}
